package Month09.day0906;

import java.util.Scanner;

public class NiuKe {
    private int year;
    private int month;
    private int day;
    public void setday(int year,int month,int day){
        this.year = year;
        this.month = month;
        this.day = day;
    }
    public static void main5(String[] args) {
        Scanner sc = new Scanner(System.in);
        NiuKe  Niu1 = new NiuKe();
        Niu1.setday(sc.nextInt(),sc.nextInt(),sc.nextInt());
        System.out.println(Niu1.day + "/" + Niu1.month + "/" + Niu1.year);
    }//BC139 KiKi定义电子日历类

    public static void main4(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[sc.nextInt()];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        int key = sc.nextInt();
        int count = 0;//加一个计数器
        for (int i = 0; i < a.length; i++) {
            if(a[i] != key){
                count++;
            }
        }
        System.out.println(count);
        for (int i = 0; i < a.length; i++) {
            if(a[i] != key){
                System.out.print(a[i] + " ");
            }
        }
        sc.close();
    }//BC138 KiKi学结构体和指针
    public static void main3(String[] args) {
        //BC137 KiKi判断上三角矩阵
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = a;
        int[][] arr = new int[a][b];
        for (int i = 0; i < a; i++) {
            for (int j = 0; j < b; j++) {
                arr[i][j] = sc.nextInt();
            }
        }
        boolean key = true;
        for (int i = 1; i < a; i++) {
            for (int j = 0; j < i; j++) {
                if(arr[i][j] != 0){
                    key = false;
                }
            }
        }
        System.out.println(key == true ? "YES" : "NO");
    }//BC137 KiKi判断上三角矩阵

    public static void main2_2(String[] args) {
        //给定一个整数序列，KiKi想把其中的重复的整数去掉，并将去重后的序列从小到达排序输出。
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[sc.nextInt()];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }//接收输入数字
        Bubble(arr);
        for (int i = 0; i < arr.length; i++) {
            for (int j = i; j < arr.length; j++) {
                if(arr[i] == arr[j] && i != j && arr[i] != 0){
                    arr[j] = 0;

                }
            }
        }
        for(int x:arr){
            if(x != 0) {
                System.out.print(x + " ");
            }
        }
    }//BC136 KiKi去重整数并排序 (思考之后的简化版)
    public static void main2(String[] args) {
        //给定一个整数序列，KiKi想把其中的重复的整数去掉，并将去重后的序列从小到达排序输出。
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[sc.nextInt()];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }//接收输入数字
        int count = 0;//决定创建新创组的大小
        for (int i = 0; i < arr.length; i++) {
            for (int j = i; j < arr.length; j++) {
                if(arr[i] == arr[j] && i != j && arr[i] != 0){
                    arr[j] = 0;
                    count++;
                }
            }
        }
        int[] arr2 = new int[arr.length - count];
        count = 0;//初始化计数器
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] != 0){
                arr2[count] = arr[i];
                count++;
            }
        }
        Bubble(arr2);
        for(int x:arr2){
            System.out.print(x + " ");
        }
    }//BC136 KiKi去重整数并排序
    public static void Bubble(int[] a){
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a.length - i - 1; j++) {
                if(a[j] > a[j + 1]){
                    int tmp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = tmp;
                }
            }
        }
    }

    public static void main1(String[] args) {
        //KiKi知道了什么是质数（只能被1和他自身整除的数），他现在想知道所有三位整数中，有多少个质数。
        int count = 0;//计数器
        for (int i = 100; i < 1000; i++) {
            boolean key = true;
            for (int j = 2; j <= Math.sqrt(i); j++) {//或者也可以写成 j * j <= i,注意这里一定要是 <= ,一定要是 <= ，我在这里错了都
                if(i % j == 0){
                    key = false;
                }
            }
            if(key == true){
                count++;
            }
        }
        System.out.println(count);
    }//BC135 KiKi求质数个数
}
